//GoodsMapper.java
package org.example.examtemplate01.Mapper;

import org.apache.ibatis.annotations.*;
import org.example.examtemplate01.module.Goods;

import java.util.List;

@Mapper
public interface GoodsMapper {


    //获取goods列表
    @Select("select * from goods")
    List<Goods> fetchGoodsList();

    //删除对应ID的goods
    @Delete("delete from goods where id=#{id}")
    int removeGoodsById(int id);

    //新增Goods
    @Insert("insert into goods(name,price,description) values(#{name},#{price},#{description})")
    int addGoods(Goods goods);

    //修改对应ID的goods
    @Select("select * from goods where id=#{id}")
    Goods fetchGoodsById(int id);

    //修改goods
    @Update("update goods set name=#{name},price=#{price},description=#{description} where id=#{id}")
    int editGoods(Goods goods);

    //分页查询
    @Select("select * from goods limit #{fromIndex},#{pageSize}")
    List<Goods> fetchByPage(int fromIndex, int pageSize);
}
